home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / ODUtils / Include / BArray.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-25  |  1.5 KB  |  63 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        BArray.h
  3.  
  4.     Contains:    ByteArray collection
  5.  
  6.     Owned by:    Vincent Lo
  7.  
  8.     Copyright:    © 1994 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     
  11. */
  12.  
  13. #ifndef _BARRAY_
  14. #define _BARRAY_
  15.  
  16. #ifndef _ODTYPES_
  17. #include <ODTypes.h>
  18. #endif
  19.  
  20. /* DisposeByteArrayStruct is a macro instead of a function so it can take a different
  21.    parameter type than DisposeByteArray(), and still set the disposed pointer field
  22.    of the structure to null.
  23.    DisposeByteArray() must never be called on a ByteArray structure; DisposeByteArray()
  24.    disposes the structure which is usually a distaster.
  25. */
  26.  
  27. #define    DisposeByteArrayStruct(byteArray)        \
  28.     do{                                            \
  29.         if (byteArray._buffer != kODNULL) {        \
  30.             ODDisposePtr(byteArray._buffer);    \
  31.             byteArray._buffer = kODNULL;        \
  32.         }                                        \
  33.         byteArray._length = 0;                    \
  34.         byteArray._maximum = 0;                    \
  35.     }while(0)
  36.  
  37.  
  38. #ifdef _OD_IMPL_SHARE_UTILS_
  39. #pragma import on
  40. #endif
  41.  
  42. extern "C" {
  43.     ODByteArray*    CreateByteArray(void* buffer, ODULong size);
  44.     ODByteArray        CreateByteArrayStruct(void* buffer, ODULong size);
  45.  
  46.     ODByteArray*    CreateEmptyByteArray(ODULong maximum);
  47.     ODByteArray        CreateEmptyByteArrayStruct(ODULong maximum);
  48.  
  49.     void UseByteArray(ODByteArray* ba, void* buffer, ODULong size);
  50.  
  51.     ODByteArray*    CopyByteArray(ODByteArray* fromBA);
  52.     ODByteArray        CopyByteArrayStruct(ODByteArray* fromBA);
  53.  
  54.     void            DisposeByteArray(ODByteArray* array);
  55.  
  56.     ODBoolean        AreByteArraysEqual(ODByteArray* ba1, ODByteArray* ba2);
  57. }
  58.  
  59. #ifdef _OD_IMPL_SHARE_UTILS_
  60. #pragma import off
  61. #endif
  62.  
  63. #endif     // _BARRAY_